import { IOrgBasicsInfo } from './model/listModel';
import {
    listParams,
    ListItemGetResultModel,
    ISmsAccountData,
} from './model/smsAccountConfigurationModel';
import { defHttp } from '@/utils/http/axios';

enum Api {
    list = '/admin/sms-apiAccount/pageList',
    addSmsAccount = '/admin/sms-apiAccount/add',
    editSmsAccount = '/admin/sms-apiAccount/edit',
    delSmsAccount = '/admin/sms-apiAccount/del',
    getSmsAccountById = '/admin/sms-apiAccount/getById',
    getSmsApiAccountOrgs = '/admin/sms-apiAccount/org/getDownList'

}

/**
 * @description 短信账户列表
 * @date 13/07/2022
 * @export
 * @param {institutionListParams} params
 */
export function list(params: listParams) {
    return defHttp.get<ListItemGetResultModel>({
        url: Api.list,
        params,
    });
}
/**
 * 新增短信账户
 * @param data 
 * @returns 
 */
export function addSmsAccount(data: ISmsAccountData) {
    return defHttp.post({
        url: Api.addSmsAccount,
        data,
    });
}

/**
 * 新增短信账户
 * @param data 
 * @returns 
 */
export function editSmsAccount(data: ISmsAccountData) {
    return defHttp.post({
        url: Api.editSmsAccount,
        data,
    });
}

/**
 * 删除短信账户
 * @param data 
 * @returns 
 */
export function delSmsAccount(id: number) {
    return defHttp.post({
        url: Api.delSmsAccount + '/' + id,

    });
}

/**
 * 短信账户详情
 * @param id 
 * @returns 
 */
export function getSmsAccountById(id: number) {
    return defHttp.get<ISmsAccountData>({
        url: Api.getSmsAccountById + '/' + id,
    });
}
/**
 * 获取短信机构列表
 * @param keyWord 
 * @returns 
 */
export function getSmsApiAccountOrgs(keyWord: string) {
    return defHttp.get<IOrgBasicsInfo[]>({
        url: Api.getSmsApiAccountOrgs,
        params: {
            keyWord
        }
    });
}